﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using WcfHelloService;

namespace WcfHelloServer
{
    class Program
    {
        static void Main(string[] args)
        {
            //using(ServiceHost serviceHost = new ServiceHost(typeof(HelloService)))
            //{
            //    serviceHost.Opened += delegate
            //    {
            //        Console.WriteLine("服务已启动！");
            //    };
            //    serviceHost.Open();
            //    //保持宿主进程及服务容器的存活,如使用using语法,则必须在using中保持服务容器的存活。
            //    Console.ReadKey();
            //}
            ////移出using外面，则服务容器就会被垃圾回收器回收
            //Console.ReadKey();


            ServiceHost serviceHost = new ServiceHost(typeof(HelloService));
            serviceHost.Opened += delegate
            {
                Console.WriteLine("服务已启动！");
            };
            serviceHost.Open();
            Console.ReadKey();
        }
    }
}
